package algorithm;

//分治算法解决汉诺塔问题
public class Hanoitower {
    static int count=0;
    public static void main(String[] args) {
        hanoitower(5, 'A', 'B', 'C');
        System.out.println(count);
    }

    public static void hanoitower(int num, char a, char b, char c) {
        count++;
        if (num == 1) {
            System.out.println("第一个盘从" + a + "->" + c);
        } else {
            hanoitower(num - 1, a, c, b);
            System.out.println("第" + num + "个盘从" + a + "->" + c);
            hanoitower(num - 1, b, a, c);
        }

    }
}
